<template>
  <div class="execution">
        <el-dialog
  title="详情"
  :visible.sync="dialogVisible1"
  :close="handleClose"
  width="80%"
  >
  <div>


            <avue-crud v-if="tableDatas.length !=0"
        ref="crud"
        :page="page2"
        :data="tableData"
        :table-loading="tableLoading"
        :option="tablecerno"
      
       
        @search-change="searchChange"
        @refresh-change="refreshChange"
        @current-change="currentChange"
        
      >
            <template slot-scope="scope" slot="fileName">
      <el-button type="text"
                   
                    
                     size="small"
                     plain

                     @click="downloadFile(scope.row)"
                     >{{scope.row.fileName}}
          </el-button>
  </template>
  

        </avue-crud>
  </div>
  <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
</el-dialog>



        <el-dialog
  title="详情"
  :visible.sync="dialogVisible"
  width="80%"
  >
  <div v-if="classfile.length !=0">


            <avue-crud v-if="tableDatas.length !=0"
        ref="crud"
        :page="page1"
        :data="tableDatas"
        :table-loading="tableLoading"
        :option="tableOptions"
        
       
        @search-change="searchChange1"
        @refresh-change="refreshChange"
        @current-change="currentChange1"
        
      >
        <template slot-scope="scope" slot="menu">
      <el-button type="text"
                   
                     icon="el-icon-check"
                     size="small"
                     plain

                     @click="details(scope.row)"
                     >详情
          </el-button>
  </template>

        </avue-crud>
  </div>
  <div v-if-else="classfile.length==0">未查找到数据！</div>
  <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
</el-dialog>



    <basic-container>
      <avue-crud
        ref="crud"
        :page="page"
        :data="classfile"
        :table-loading="tableLoading"
        :option="tableOption"
       
       
        @search-change="searchChange"
        @refresh-change="refreshChange"
        @current-change="currentChange"
        
      >


      


  <template slot-scope="scope" slot="menu">
      <el-button type="text"
                   
                     icon="el-icon-check"
                     size="small"
                     plain

                     @click="btn(scope.row)"
                     >详情
          </el-button>
  </template>

        
      </avue-crud>



    </basic-container>
  </div>
</template>
<script>

  import { writeOff ,download,getCategory,getCertNo} from '@/api/antborrow/writeOff'


   import {fileName} from '@/const/crud/antborrow/fileName'
   import {tableOption} from '@/const/crud/antborrow/writeOff'
   import {cerno} from '@/const/crud/antborrow/cerno'

  import {mapGetters} from 'vuex'

  export default {
    name: 'stareportfile',
    data() {
      return {
        dialogVisible:false,
        dialogVisible1:false,
        
        classfile:[
        
        ],
        queryParams: {},
        tableData: [],
        tableDatas:[],
        numberindex:{},
        page: {
          current: 1,
          size: 10,
          total:0
        },
        page1: {
          current: 1,
          size: 10,
          total:0
        },
          page2: {
          current: 1,
          size: 10,
          total:0
        },
      
        
        tableLoading: false,
        tableOption: fileName,
        tableOptions:tableOption,
        tablecerno:cerno
      }
    },
    created() {
      getCategory({
        current:1,
        size:10
      }).then(res=>{
      
       
        this.classfile = res.data.data.records
        this.page.total =res.data.data.total
      })
    },
    mounted(){
      
    },
    computed: {
      ...mapGetters(['permissions'])
    },
    components: {},
    methods: {

      searchChange1(form){
         this.$set(this.numberindex,'certNo',form.certNo);
         this.$set(this.numberindex,'name',form.name);
        
               getCertNo({
        cancelCategory: this.numberindex.cancelCategory,
        cancelDate: this.numberindex.cancelDate,
        certNo:this.numberindex.certNo,
        name:this.numberindex.name,
        current:1,
        size: 10
        }).then(res=>{
         
            this.tableDatas =res.data.data.records
            this.page1.total =res.data.data.total
        })
      },
      currentChange1(current){
        
   
        
       
        this.page1.current =current
        
          getCertNo({
        cancelCategory: this.numberindex.cancelCategory,
        cancelDate: this.numberindex.cancelDate,
        current,
        size: 10
        }).then(res=>{
         
            this.tableDatas =res.data.data.records
            this.page1.total =res.data.data.total
        })
      },
      btn(index){
        this.numberindex =index
        this.dialogVisible = true
        
        getCertNo({
        cancelCategory: index.cancelCategory,
        cancelDate: index.cancelDate,
        current: 1,
        size: 10
        }).then(res=>{
         
            this.tableDatas =res.data.data.records
            this.page1.total =res.data.data.total
        })
      },

      details(row){
        
        this.dialogVisible1 = true
         this.$set(this.page1,'certNo',row.certNo);
         this.$set(this.page1,'cancelDate',row.cancelDate);
         this.$set(this.page1,'cancelCategory',row.cancelCategory);
         console.log(this.page1);
         this.getList()

      },



      downloadFile(row) {
        
       download(row.id).then(response=>{
         
          let blob = new Blob([response.data], { type: "application/zip" });
          let url = window.URL.createObjectURL(blob);
          link.href = url;
          link.click();
          this.checkList = [];



       })
      },
      downloadFiles(id){
     
           download(id).then(response=>{
         
          let blob = new Blob([response.data], { type: "application/zip" });
          let url = window.URL.createObjectURL(blob);
          link.href = url;
          link.click();
          this.checkList = [];
       })
      },
      handleClose(){
        this.dialogVisible1 = false
      },
     getList() {
        this.tableLoading = true
        writeOff(
            this.page1
        ).then(res=>{
        
          this.tableData = res.data.data.records
          this.page2.total =res.data.data.total
          this.tableLoading = false
        })
      },
      /**
       */
      searchChange(form) {
         this.$set(this.page,'cancelContractNo',form.cancelContractNo);
         this.$set(this.page,'cancelCategory',form.cancelCategory);
       
      },
      /**
       */
      refreshChange() {
      
      },


      currentChange(page){
       
      
       
      }
    }
  }
</script>

<style lang="scss" scoped>

</style>
